/*
 * @Author: zhang_xm3@ecidi.com
 * @Date: 2019-11-23 14:30:50
 * @LastEditors: wei_jt@ecidi.com
 * @LastEditTime: 2021-09-24 14:16:46
 * @Description: 表单通用api，包括文件上传中使用的api
 */
import request from "@/utils/request"

/**
 * @description: 获取流程评论
 * @param {data}
 */
export function getProcessHistory (params) {
  return request({
    method: "get",
    url: "/sys-bpm/process/history",
    params: params
  })
}

/**
 * @description: 获取流程进行时的流程信息，用于展示流程图
 */
export function getHistoryNodes (params) {
  return request({
    method: "get",
    url: "/sys-bpm/process/history/instance",
    params: params
  })
}

/**
 * @description: 获取流程图xml
 */
export function getModelXML (data) {
  return request({
    method: "get",
    url: "/sys-bpm/model",
    params: {
      id: data.id,
      modelKey: data.modelKey,
    },
  })
}

// 表单提交通用接口
export function submitForm (url, data) {
  return request({
    url: url,
    method: "post",
    data,
  })
}
//废弃流程
export function processAbandon (data) {
  return request({
    method: 'delete',
    url: '/sys-bpm/process/',
    params: {
      taskId: data.taskId,
      comment: data.comment || '',
      fileToken: data.fileToken
    }
  })
}
// 表单初始化通用接口
export function getFormData (url, data) {
  return request({
    url: url,
    method: "post",
    data: {
      id: data.bizId,
      entityName: data.entityName,
      detailEntityNameList: data.detailEntityNameList,
    },
  })
}
// 自由流程表单 查询 通用接口
export function initialCustomForm (data) {
  return request({
    url: '/sys-form/form/data',
    method: "get",
    params: data
  })
}
// 新增自定义表单
export function addCustomFormConfig (data) {
  return request({
    url: '/sys-form/form',
    method: "post",
    data: data
  })
}
// 查询自定义表单详情
export function getCustomFormConfig (data) {
  return request({
    url: '/sys-form/form',
    method: "get",
    params: data
  })
}
// 查询历史自定义表单详情
export function getHistoryCustomFormConfig (data) {
  return request({
    url: '/sys-form/form/history',
    method: "get",
    params: data
  })
}
// 自定义表单  查询当前节点表单字段权限信息
export function getNodePermission (data) {
  return request({
    url: '/sys-bpm/process/formPerssion',
    method: "get",
    params: data
  })
}
// 自由流程表单 新增/更新 通用接口
export function submitCustomForm (data) {
  return request({
    url: '/sys-form/form/data',
    method: "post",
    data
  })
}
// 自由流程表单 删除 通用接口
export function deleteCustomForm (formKey, id) {
  return request({
    url: '/sys-form/form/data',
    method: "delete",
    params: {
      formKey,
      id
    }
  })
}
/**
 * @description: 查询任务待办详情
 */
export function getUserTaskDetail (taskId) {
  return request({
    url: "/sys-bpm/userTask",
    method: "get",
    params: {
      taskId: taskId
    }
  })
}



